from django.contrib import admin
from apps.goods.models import GoodsType, GoodsSKU, Goods, GoodsImage, IndexGoodsBanner, IndexTypeGoodsBanner, \
    IndexPromotionBanner
from django_summernote.admin import SummernoteModelAdmin
from import_export.admin import ImportExportModelAdmin


# Register your models here.

@admin.register(Goods)
class GoodsAdmin(SummernoteModelAdmin):
    list_display = ['id', 'name', 'detail']
    list_display_links = ['name']
    list_filter = ['name']
    list_per_page = 10
    summernote_fields = ('detail',)


@admin.register(GoodsType)
class GoodsTypeAdmin(admin.ModelAdmin):
    list_display = ['name', 'logo']
    list_display_links = ['name']
    list_filter = ['name']


@admin.register(GoodsSKU)
class GoodsSKUAdmin(ImportExportModelAdmin, SummernoteModelAdmin):
    list_display = ['name', 'type', 'goods', 'price', 'unite', 'stock', 'sales', 'status']
    list_display_links = ['name']
    list_filter = ['name', 'type', 'goods', 'status']


@admin.register(GoodsImage)
class GoodsImageAdmin(admin.ModelAdmin):
    list_display = ['sku', 'image']
    list_display_links = ['sku']
    list_filter = ['sku']


@admin.register(IndexPromotionBanner)
class IndexPromotionBannerAdmin(admin.ModelAdmin):
    list_display = ['name', 'url', 'index']
    list_display_links = ['name']
    list_filter = ['name']


@admin.register(IndexGoodsBanner)
class IndexGoodsBannerAdmin(admin.ModelAdmin):
    list_display = ['sku', 'index']
    list_display_links = ['sku']
    list_filter = ['sku']


@admin.register(IndexTypeGoodsBanner)
class IndexTypeGoodsBannerAdmin(admin.ModelAdmin):
    list_display = ['sku', 'type', 'display_type']
    list_display_links = ['type', 'sku']
    list_filter = ['type', 'sku']


from utils import web_site
